package com.atguigu.rabbitmq.producer.config;


import org.springframework.amqp.core.*;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// com.atguigu.rabbit.producer.config;
@Configuration
public class RabbitmqFanoutExchangeConfiguration {

    // 声明交换机
    @Bean
    public Exchange fanoutExchange() {
        return ExchangeBuilder.fanoutExchange("fanout_exchange").durable(true).build();
    }

    // 声明队列
    @Bean
    public Queue fanoutQueue01() {
        return QueueBuilder.durable("fanout_queue_01").build();
    }

    // 声明队列
    @Bean
    public Queue fanoutQueue02() {
        return QueueBuilder.durable("fanout_queue_02").build();
    }

    // 声明队列和交换机的绑定信息 后面在给交换机fanout_exchange发消息相当于也给fanout_queue_01发消息
    @Bean
    public Binding fanoutQueue01Binding() {
        return BindingBuilder.bind(fanoutQueue01()).to(fanoutExchange()).with("").noargs();
    }

    // 声明队列和交换机的绑定信息 后面再给交换机fanout_exchange发消息相当于也给fanout_queue_02发消息
    @Bean
    public Binding fanoutQueue02Binding() {
        return BindingBuilder.bind(fanoutQueue02()).to(fanoutExchange()).with("").noargs();
    }

}